package com.health.controller;

import com.health.vo.Result;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 处理全局异常
 */
@RestControllerAdvice
public class ExceptionController {
    public static final Logger LOGGER= LogManager.getLogger(ExceptionController.class);

    @ExceptionHandler(Exception.class)
    public Object exceptionHandler(Exception e){
        //打印信息到日志中
        LOGGER.error("请求异常:"+e);

        return new Result(true,"请求异常",e.getMessage());
    }

}
